package com.cakeclient;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import com.actionbarsherlock.app.SherlockFragment;

/**
 * Created by IntelliJ IDEA.
 * User: isen
 * Date: 29/03/12
 * Time: 22:07
 * To change this template use File | Settings | File Templates.
 */
public class ClientFeedBackFragment extends SherlockFragment {
    private Button sendButton;
    private EditText clientName;
    private EditText clientFeedback;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        return inflater.inflate(R.layout.client_feedback_layout, container, false);

    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);    //To change body of overridden methods use File | Settings | File Templates.
        sendButton = (Button) getSherlockActivity().findViewById(R.id.client_feedback_send_button);
        clientName = (EditText) getSherlockActivity().findViewById(R.id.client_feedback_name_edittext);
        clientFeedback =  (EditText) getSherlockActivity().findViewById(R.id.client_feedback_edittext);
        sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
                sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "feedback@vincentcotro.fr" });
                sendIntent.setData(Uri.parse("feedback@vincentcotro.fr"));
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Client Feedback: " + clientName.getText());
                sendIntent.setType("plain/text");
                sendIntent.putExtra(Intent.EXTRA_TEXT, clientFeedback.getText());
                startActivity(sendIntent);
            }
        });
    }
}
